<!--#include file="Firewall.asp"-->
<!--#include file="Ini.asp"-->
<!--#include file="../AspLib/Functions.asp"-->

<%

sESCOLA = Request.QueryString("ESCOLA") 

Response.expires = 0
MSQL="SELECT * FROM PNLD_2007_MUN_ESC_LIVRO "
MSQL=MSQL & " WHERE CODESC='"& SESCOLA &"' ORDER BY EDITORA,TITULO,SERIE"
Set Conn = Server.CreateObject("ADODB.Connection")
conn.CommandTimeout = 1500
Conn.Open sCo1, sCo2, sCo3
Set rs = Conn.Execute(MSql)			 
'response.write msql
'response.end
IF RS.EOF THEN
  RESPONSE.END
END IF

%>
<html>
<head>
<title><% = sTitle %></title>
</head>
<% = sBODY %>
<% = sCABECALHO %>VENDAS PNLD 2007</font></b></div>
<table border='1' <% =  sTABLE %>>
  <tr bgcolor='<% = COR_TARJA %>'>
    <td><b>Edit</b></td>
    <td align='right'><b>Ser</b></td>
    <td><b>Livro</b></td>
    <td align='right'><b>Qtd</b></td>
    <td align='right'><b>Valor</b></td>
  </tr><%
  mcnt=0
  GQTD=0
  GVAL=0
  mcnte=0
  GQTDE=0
  GVALE=0
  

  Do while not rs.eof
    mcnte=0
    GQTDE=0
    GVALE=0
    medi=rs("EDITORA")
    medif=rs("EDITORA")
  Do while not rs.eof and medi=medif
 
    mcnt=mcnt+1
    GQTD=GQTD+rs("QTD")
    GVAL=GVAL+rs("VALOR")
    mcntE=mcntE+1
    GQTDE=GQTDE+rs("QTD")
    GVALE=GVALE+rs("VALOR")
    IF rs("QTD")=0 THEN
     MQTD=1
     MVVV=1
    ELSE
     MQTD=rs("QTD")
     MVVV=rs("VALOR")
    END IF
    %><TR>
     <td>&nbsp;<% = rs("EDITORA") %></td>
     <td>&nbsp;<% = rs("SERIE") %></td>
     <td>&nbsp;<% = rs("TITULO") %></td>
    <td align='right'><% = FORMATNUMBER(rs("QTD"),0) %></td>
    <td align='right'><% = FORMATNUMBER(rs("VALOR"),2) %></td>
    </tr><%
    rs.MoveNext  
    if not rs.eof then
      medif=rs("EDITORA")
    else
      medif="zzzzzz"
    end if   	
  loop
	  %><tr>
	  <td colspan='3'><B>Total = <% = MCNTE %> ITENS<br></td>
	  <td align='right'><B><% = FORMATNUMBER(GQTDE,0)  %></td>
	  <td align='right'><B><% = FORMATNUMBER(GVALE,2)  %></td>
   </tr><%
  loop

	  %><tr>
	  <td colspan='3'><b>Total Escola <% = MCNT %> ITENS<br></b></td>
	  <td align='right'><B><% = FORMATNUMBER(GQTD,0)  %></td>
	  <td align='right'><B><% = FORMATNUMBER(GVAL,2)  %></td>
   </tr>
</table>
</body>
</html>
